<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
<#include "../common/header.ftl">
    <script src="/js/plugins/chosen/chosen.jquery.js"></script>
    <link rel="stylesheet" href="/js/plugins/chosen/component-chosen.css"/>
    <script>
        $(function () {
            $('#pagination').twbsPagination({
                totalPages: ${result.pages},
                startPage: ${result.pageNum},
                visiblePages: ${result.pageSize},
                first: "首页", prev: "上一页",
                next: "下一页",
                last: "末页",
                onPageClick: function (event, page) {
                    $("#currentPage").val(page);
                    $("#searchForm").submit();
                }
            });
            //添加攻略按钮
            $("#addBtn").click(function () {
                $("#editForm")[0].reset();
                $("#coverImg").attr('width', 0);
                $("#place").trigger("chosen:updated");
                $("#strategyModal").modal("show");
            });
            //修改按钮
            $(".editBtn").click(function () {
                $("#editForm")[0].reset();
                var json = $(this).data("json");
                $("#strategyId").val(json.id);
                $("#title").val(json.title);
                $("#subTitle").val(json.subTitle);
                $("#state").val(json.state);
                //封面
                $("#coverImg").attr('width', 100);
                $("#coverImg").attr('src', json.coverUrl);
                $("#coverUrl").val(json.coverUrl);
                //回显地区下拉框
                //普通方式
                $("#place option[value=" + json.placeId + "]").prop('selected', true);
                //让插件执行更新操作
                $("#place").trigger("chosen:updated");
                $("#strategyModal").modal('show');
            })
            //保存按钮
            $("#saveBtn").click(function () {
                $("#editForm").ajaxSubmit(function (data) {
                    showMessager(data);
                })
            })

        })
    </script>
</head>
<body>

<div class="container " style="margin-top: 20px">
<#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-3">
        <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">保险管理</h1>
                </div>
            </div>
            <!--高级查询-->
            <form class="form-inline" id="searchForm" action="/insurance/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label for="keyword">关键字:</label>
                    <input type="text" class="form-control" id="keyword" name="keyword" value="${(qo.keyword)!}"
                           placeholder="请输入标题">
                    <button id="btn_query" class="btn btn-success">查询</button>
                </div>
            </form>
            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>保险名字</th>
                    <th>保险类型</th>
                    <th>客户名字</th>
                    <th>购买时间</th>
                    <th>保险时间</th>
                    <th>保险人数</th>
                </tr>
                </thead>
            <#list result.list as entity>
                <tr>
                    <td>${entity_index+1}</td>
                    <td>${entity.insuranceName}</td>
                    <td>${entity.insuranceType}</td>
                    <td>${(entity.clientName)!}</td>
                    <td>${(entity.buyTime)!}</td>
                    <td>${(entity.insuranceTime)!}</td>
                    <td>
                        <#if entity.insuranceNum == 1>
                            一人游
                        <#elseif entity.insuranceNum ==2>
                            二人游
                        <#elseif entity.insuranceNum ==2>
                            三人游
                        </#if>
                    </td>

                    <td>
                        <a href="javascript:;" class="editBtn" data-json='${entity.jsonString}'>修改</a>
                    </td>
                </tr>
            </#list>
            </table>
            <div style="text-align: center;">
                <ul id="pagination" class="pagination"></ul>
            </div>
        </div>
    </div>
</div>
</body>
</html>